cmake_minimum_required(VERSION 3.11)
project(seat_mqtt_bridge)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(ament_index_cpp REQUIRED)

# 查找MQTT和JSON库
find_package(PkgConfig REQUIRED)
pkg_check_modules(MOSQUITTO REQUIRED libmosquitto)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)

# 包含目录
include_directories(
  include
  ${MOSQUITTO_INCLUDE_DIRS}
  ${JSONCPP_INCLUDE_DIRS}
)

add_executable(seat_mqtt_bridge src/seat_mqtt_bridge.cpp)

#target_include_directories(seatmqttbridge PUBLIC
#  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
#  $<INSTALL_INTERFACE:include>)
#target_compile_features(seatmqttbridge PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(
  seat_mqtt_bridge
 # "rclcpp"
  rclcpp
  std_msgs
  ament_index_cpp
)
# 链接库
target_link_libraries(seat_mqtt_bridge
  ${MOSQUITTO_LIBRARIES}
  ${JSONCPP_LIBRARIES}
)

install(TARGETS seat_mqtt_bridge
  DESTINATION lib/${PROJECT_NAME})
# 安装launch文件
install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}/
)
# 安装配置文件
install(DIRECTORY
  config
  DESTINATION share/${PROJECT_NAME}/
)

ament_package()
